//pwa
import { VitePWA } from 'vite-plugin-pwa'

export default function createVitePWA() {
  return VitePWA({
    manifest: {
      name: '应用名称',
      id: 'cs001',
      start_url: 'index.html',
      short_name: '应用名称',
      description: '应用描述',
      theme_color: '#182330',
      background_color: '#FFFF00',
      icons: [
        //添加图标， 注意路径和图像像素正确
        {
          src: '/app-logo.png',
          sizes: '296x296',
          type: 'image/png'
        }
      ],
      //屏幕截图
      screenshots: [
        {
          'src': '/app-logo.png',
          'type': 'image/png',
          'sizes': '296x296',
          'form_factor': 'narrow'
        },
        {
          'src': '/app-logo.png',
          'type': 'image/png',
          'sizes': '296x296',
          'form_factor': 'wide'
        }
      ]
    },
    registerType: 'autoUpdate',
    workbox: {
      // 缓存相关静态资源，这个放开会导致页面html被缓存，谨慎使用
      globPatterns: ['**/*.{js,css,html,ico,png,jpg,svg}'],
      globIgnores: ['**/node_modules/**/*', 'sw.js', 'sw.js', 'workbox-*.js']
    },
    devOptions: {
      enabled: true
    }
  })
}
